\name{GetSamplingUnitID}
\alias{GetSamplingUnitID}
%- Also NEED an '\alias' for EACH other topic documented here.
\title{Get the PRBOdb unique site identifier for a specific PRBO site(station) code  }
\description{
  PRBOdb uses a unique numeric id.  However, PRBO uses a unique site code (generally 4 or 6 characters).  
  This function provides the unique numeric id based on the site code
}
\usage{
GetSamplingUnitID(station = NULL, station_name = NULL, batch = FALSE, ...)
}
%- maybe also 'usage' for other objects documented here.
\arguments{
  \item{station}{ A vector of PRBO PointCountStationIDs }
  \item{station_name}{ A vector of full length point count station names }
  \item{batch}{Boolean variable to denote whether this process should be done in batch mode.  Not yet implemented.}
  \item{\dots}{Additional variables that can get passed through to underlying functions}
}
\details{
  This function will query the PRBOdb database and retrieve the
  PRBOdb SamplingUnitID for a given set of either the unique
  station identifiers (PointCountStationID) or the long
  descriptive names for the stations.
}
\value{
  Returns a vector of SamplingUnitIDs of the same length as that provided for the search.
}

\author{ Mark Herzog \email{mherzog@prbo.org} }


\seealso{ \code{\link{GetPointCountStationID}}, \code{\link{GetStationName}} }
\examples{
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--    or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function(station=NULL, station_name=NULL, batch=FALSE, ...) {
    if (is.null(station) & is.null(station_name)) stop("A station code or station_name must be provided")
    if (!is.null(station)) {
        station.list<-paste("'",station,"'",sep="",collapse=",")
        query<- paste(  "SELECT SamplingUnitID",
                        "FROM SamplingUnit",
                        "WHERE SamplingUnitTypeCd != 'PointCountStation'",
                        "AND PointCountStationID IN (",station.list,")"
                )
    } else {
        station.list<-paste("'",station_name,"'",sep="",collapse=",")
        query<- paste(  "SELECT SamplingUnitID",
                        "FROM SamplingUnit",
                        "WHERE SamplingUnitTypeCd != 'PointCountStation'",
                        "AND SamplingUnitName IN (",station.list,")"
                )    
    }
    query.results<-fetch(dbSendQuery(db<-PRBOdbConnect(group="PRBOdb", ...),query),n=-1)
    dbDisconnect(db)
    return(query.results[,1])
  }
}
% Add one or more standard keywords, see file 'KEYWORDS' in the
% R documentation directory.
\keyword{ data }
